package com.ziyun.pop.common.utils;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @Author ZhaoWei
 * @Date 2018/10/11 11:22
 * @Version V1.0
 */
public class StorematerialinUtils {

	private static Logger logger = LoggerFactory.getLogger(StorematerialinUtils.class);

	private static String AutoNo(int sellerId, StringBuffer purchaseApplyNo) {
		if(sellerId < 10){
			purchaseApplyNo.append(0).append(sellerId);
		}else{
			purchaseApplyNo.append(sellerId);
		}

		SimpleDateFormat dateFormat = new SimpleDateFormat("yyMMdd");
		String formatStr =dateFormat.format(new Date());
		purchaseApplyNo.append(formatStr);

		//随机数
		int one = (int)(Math.random()*10);
		int two = (int)(Math.random()*10);
		int three = (int)(Math.random()*10);

		purchaseApplyNo.append(one).append(two).append(three);
		logger.info("生成调出单号："+purchaseApplyNo.toString());
		return purchaseApplyNo.toString();
	}

	/**
	 * @author   Alix_zw
	 * @Description   生成调出单据号

	 * @Return    TT(Transfer to) + 2位门店ID + YYMMDD + 3位随机数
	 **/

	public static synchronized String produceTransferToNo(int sellerId){

		StringBuffer transferToNo = new StringBuffer("TT");
		return AutoNo(sellerId, transferToNo);
	}

}
